import { createRouter, createWebHistory } from 'vue-router'

const routes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/login.vue'),
        meta: { title: '登录' }
    },
    {
        path: '/',
        name: 'home',
        component: () => import('@/views/Client/home.vue'),
        redirect: '/home',
        children: [
            {
                path: 'home',
                component: () => import('@/views/Client/index.vue'),
                meta: { title: '首页' }
            },
            {
                path: 'detail',
                component: () => import('@/views/Client/detail.vue'),
                meta: { title: '电影详情' }
            },
            {
                path: 'my',
                component: () => import('@/views/Client/my.vue'),
                meta: { title: '个人中心' }
            }
        ]
    },
    {
        path: '/admin',
        name: 'admin',
        component: () => import('@/views/Admin/layout.vue'),
        redirect: '/admin/cinema',
        children: [
            {
                path: 'cinema',
                component: () => import('@/views/Admin/cinema.vue'),
                meta: { title: '影院管理' }
            },
            {
                path: 'room',
                component: () => import('@/views/Admin/room.vue'),
                meta: { title: '影厅管理' }
            },
            {
                path: 'movie',
                component: () => import('@/views/Admin/movie.vue'),
                meta: { title: '电影管理' }
            },
            {
                path: 'movietype',
                component: () => import('@/views/Admin/movie_type.vue'),
                meta: { title: '电影类型管理' }
            },
            {
                path: 'time',
                component: () => import('@/views/Admin/time.vue'),
                meta: { title: '场次管理' }
            },
            {
                path: 'order',
                component: () => import('@/views/Admin/order.vue'),
                meta: { title: '订单管理' }
            }
        ]
    }
]
const router = createRouter({
    history: createWebHistory(),
    routes,
});
router.beforeEach((to, from, next) => {
    document.title = to.meta.title
    next()
})
export default router;